﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LitJson;
using HDAPI;

public partial class Test_Scripts_NormalBrowser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Response.Write("1. Detect all capabilities of the device device");
            HDBase hd = new HDBase(Request);
            if (hd.detectAll())
            {
                JsonData data = hd.getDetectAll();
                foreach (System.Collections.Generic.KeyValuePair<string, JsonData> o in data)
                {
                    Append(InfoType.Success, o.Key + ":" + o.Value.ToJson() + "<br>");
                }
                Append(InfoType.Success, "Detectall API call succeessful");
                Session["5"] = "<font color='green'>API call successful.</font>";
            }
            else
            {
                Append(InfoType.Error, hd.getError());
                Session["5"] = "<font color='red'>" + hd.getError() + "</font>";
            }
        }
        catch (Exception ex)
        {
            Append(InfoType.Error, ex.Message);
        }
    }
    public void Append(InfoType tp, string information)
    {
        string color = "Green";
        if (tp == InfoType.Error)
        {
            color = "Red";
        }
        lblMessage.Text += "<font color='" + color + "'>" + information + "</font><br/>";
    }
    public enum InfoType
    {
        Error = 0,
        Success = 1
    }
}
